import { ref, computed, watch } from 'vue'
import { defineStore } from 'pinia'

export default defineStore('login', () => {
  const token = ref<string>("")
  const userInfo = ref<any>({})
  const momentInfo = ref<any>({})
  const isLogin = computed(() => token.value !== '')
  const setToken = (params: string) => {
    token.value = params
  }
  const setUserInfo = (userInfo: any) => {
    userInfo.value = userInfo
  }
  const setMomentInfo = (momentInfo: any) => {
    if(momentInfo) {
      momentInfo.value = momentInfo
    }
  }
  const getToken = () => {
    return token.value
  }
  return { isLogin, token, userInfo, momentInfo, getToken, setUserInfo, setToken, setMomentInfo }
})
